home *** CD-ROM | disk | FTP | other *** search
- (*
-
- General purpose TSR code, placed in the public domain by Lane H. Ferris as
- STAYRES3.ARC. This file is STAYRES.320 plus include files with comments, blank
- lines and redundant spaces removed. See the original STAYRES code for comments
- and explanation of what's going on. Pascal source compression done by Saxman
- Software COMPRESS.COM utility.
-
- Look for comments "User Varibles" or "User Code". These mark places one is most
- likely to add code for custom TSR routines. Important: Compile this to a COM
- file with mAximum free memory around 300-400. If you get "memory allocation
- error" or "cannot load COMMAND.COM", you probably forgot to do this.
-
- *)
- {$C-}
- Program STAYRES;
- const
- Our_Char = 113;
- Quit_Key = 119;
- User_Int = $67;
- Kybrd_Int = $16;
- Type
- Regtype = record Ax,Bx,Cx,Dx,Bp,Si,Di,Ds,Es,Flags:integer end;
- HalfRegtype = record Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh:byte end;
- Const
- Regs : regtype = (Ax:0;Bx:0;Cx:0;Dx:0;Bp:0;Si:0;Di:0;Ds:0;Es:0;Flags:0);
- OurDseg : integer = 0;
- OurSseg : integer = 0;
- DosSseg : integer = 0;
- Inuse : Boolean = false;
- User_IntIP : integer = 0;
- User_IntCs : integer = 0;
- Var
- SaveRegs : regtype;
- HalfRegs : halfregtype absolute regs;
- Terminate_flag : boolean ;
- Keychr : char ;
- (*========================= Begin User Variables ===========================*)
- (*========================== End User Variables ============================*)
- Procedure Stay_Xit;
- Begin
- Writeln ('StayRes Returning memory to DOS') ;
- SaveRegs.Ax := $35 shl 8 + User_Int;
- MsDos(SaveRegs);
- SaveRegs.Ax := $25 shl 8 + Kybrd_Int;
- SaveRegs.Ds := SaveRegs.Es;
- SaveRegs.Dx := SaveRegs.Bx;
- MsDos(SaveRegs);
- MemW[$00:User_Int * 4] := 0 ;
- MemW[$00:User_Int * 4 + 2] :=0;
- Saveregs.Ax := $49 shl 8 + 0 ;
- Saveregs.Es := MemW[Cseg:$2C] ;
- MsDos( Saveregs ) ;
- Saveregs.Ax := $49 shl 8 + 0 ;
- Saveregs.Es := Cseg ;
- MsDos( Saveregs ) ;
- Intr($20,Regs) ;
- End;
- Procedure Process_Intr;
- Begin
- Inline (
- $80/$FC/$00/
- $74/$07/
- $5D/$5D/
- $2E/
- $FF/$2E/User_IntIP/
- $FA /
- $55/
- $BD/Regs/
- $2E/$89/$46/$00/
- $2E/$89/$5E/$02/
- $2E/$89/$4E/$04/
- $2E/$89/$56/$06/
- $2E/$8F/$46/$08/
- $2E/$89/$76/$0A/
- $2E/$89/$7E/$0C/
- $2E/$8C/$5E/$0E/
- $2E/$8C/$46/$10/
- $9C/
- $2E/$8F/$46/$12/
- $2E/$80/$3E/Inuse/$01/
- $74/$57/
- $2E/$8C/$16/DosSSeg/
- $8C/$D6/
- $8E/$C6/
- $2E/$8E/$16/OurSSeg/
- $2E/$8E/$1E/OurDseg/
- $2E/$3B/$36/OurSSeg/
- $89/$E6/
- $74/$05/
- $3E/$8B/$36/$74/$01/
- $87/$F4/
- $2E/$FF/$76/$00/
- $2E/$FF/$76/$02/
- $2E/$FF/$76/$04/
- $2E/$FF/$76/$06/
- $2E/$FF/$76/$0A/
- $2E/$FF/$76/$0C/
- $2E/$FF/$76/$0E/
- $2E/$FF/$76/$10/
- $B9/>$0028/
- $26/$FF/$34/
- $46/$46/
- $E2/$F9/
- $2E/$8E/$16/OurSSeg/
- $56/
- $2E/$8C/$5E/$0E/
- $FB
- ) ;
- Intr (User_Int, Regs);
- If (Halfregs.Ah = Quit_Key) then
- stay_xit
- else
- If (Halfregs.Ah = Our_Char)
- then if (not InUse) then
- Begin
- InUse := true;
- (*============================ Begin User Code =============================*)
- (*============================= End User Code ==============================*)
- Regs.Ax := $1D00;
- InUse := false;
- End;
- inline(
- $BD/Regs/
- $2E/$8B/$46/$00/
- $2E/$8B/$5E/$02/
- $2E/$8B/$4E/$04/
- $2E/$8B/$56/$06/
- $2E/$8B/$76/$0A/
- $2E/$8B/$7E/$0C/
- $2E/$8E/$5E/$0E/
- $2E/$8E/$46/$10/
- $2E/$FF/$76/$12/
- $9D/
- $2E/$80/$3E/Inuse/$01/
- $74/$23/
- $FA /
- $5E/
- $B9/>$0028/
- $2E/$8E/$06/DosSSeg/
- $4E/$4E/
- $26/$8F/$04/
- $E2/$F9/
- $89/$F5/
- $07/
- $1F/
- $5F/
- $5E/
- $5A/
- $59/
- $5B/
- $44/$44/
- $89/$EC/
- $2E/$8E/$16/DosSSeg/
- $5D/
- $BD/Regs/
- $2E/$FF/$76/$12/
- $9D/
- $5D/
- $FB/
- $CA/$02/$00
- );
- End;
- Begin
- InUse := false;
- OurDseg:= Dseg;
- OurSseg:= Sseg;
- Terminate_Flag := false ;
- SaveRegs.Ax := $35 shl 8 + User_Int;
- Intr($21,SaveRegs);
- if SaveRegs.Es <> $00 then
- WriteLn ('Interrupt in use -- can''t install StayRes as Resident Code')
- else
- begin
- SaveRegs.Ax := $35 shl 8 + Kybrd_Int;
- Intr($21,SaveRegs);
- SaveRegs.Ax := $25 shl 8 + User_Int;
- SaveRegs.Ds := SaveRegs.Es;
- SaveRegs.Dx := SaveRegs.Bx;
- Intr($21,SaveRegs);
- SaveRegs.Ax := $25 shl 8 + Kybrd_Int;
- SaveRegs.Ds := Cseg;
- SaveRegs.Dx := Ofs(Process_Intr);
- Intr ($21,SaveRegs);
- User_IntIp := MemW[0:User_Int * 4 ];
- User_IntCs := MemW[0:User_Int * 4 +2];
- Writeln(' Program Memory Resident.');
- WriteLn(' Press Alt-F10 to activate.');
- WriteLn(' Press Ctrl-Home to un-install.');
- SaveRegs.Ax := $31 shl 8 + 0 ;
- SaveRegs.Dx := MemW [Cseg-1:0003] ;
- Intr ($21,SaveRegs);
- end;
- end.